package com.my.config;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author mayong
 * @since 2024/4/2
 */
@Configuration
public class SpringdocConfig {

    @Bean
    public OpenAPI defaultOpenAPI() {
        return new OpenAPI()
                .info(info())
                .components(new Components().addSecuritySchemes("Authorization", new SecurityScheme().name("认证").type(SecurityScheme.Type.HTTP)
                        .description("JWT认证").scheme("bearer").bearerFormat("JWT")));
    }

    public Info info() {
        return new Info()
                .title("CODING-API")
                .version("V1.0")
                .description("基于swagger3.0在线接口文档")
                .contact(new Contact().name("马勇").email("my_ong123@163.com"));
    }

}
